package com.nioEx;

import java.nio.ByteBuffer;

public class CompactEx {

    
    public static void main(String[] args) {
        
        
        ByteBuffer b=ByteBuffer.allocate(20);
        b.put("helloworld".getBytes());
         b.flip();
        System.out.println((char)b.get());
        b.position(2);
        b.flip();
        System.out.println((char)b.get());
        b.compact();
         b.flip();
        System.out.println((char)b.get());
        
        
        
        
    }
}
